class MinStack(object):
    # 栈，队列，堆的区别：https://blog.csdn.net/m0_37622530/article/details/81429837
    def __init__(self):
        """
        initialize your data structure here.
        """
        self.stack = list()
        self.min_value = []
    def push(self, x):
        """
        :type x: int
        :rtype: None
        """
        self.stack.append(x)
        for i in range(len(self.min_value)-1, -1, -1):
            if self.min_value[i] < x:
                self.min_value.insert(i+1, x)
                break
        else:
            self.min_value.insert(0, x)


    def pop(self):
        """
        :rtype: None
        """
        value = self.stack.pop()
        self.min_value.pop(self.min_value.index(value))
    def top(self):
        """
        :rtype: int
        """
        return self.stack[-1]

    def getMin(self):
        """
        :rtype: int
        """
        return self.min_value[0]

# Your MinStack object will be instantiated and called as such:
# obj = MinStack()
# obj.push(x)
# obj.pop()
# param_3 = obj.top()
# param_4 = obj.getMin()